package ru.st.selenium.pages;

import static org.openqa.selenium.support.ui.ExpectedConditions.*;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;

public class SearchPage extends InternalPage {
	
	public SearchPage (PageManager pages) {
		super(pages);
	}
	
	 @FindBy (id = "q")
	  private WebElement searchLink;
	 
	 public SearchPage setSearchField(String text) {
		 searchLink.sendKeys(text);
		 searchLink.sendKeys(Keys.RETURN);
		 	 
	    return this;
	  }
	 
	 public SearchPage ensurePageLoaded() {
		    super.ensurePageLoaded();
		    wait.until(presenceOfElementLocated(By.xpath("//div[@class='title' and text()='Gravity']")));
		    return this;
		  }   
}
